package outputStream;

import java.io.FileNotFoundException;
import java.io.FileOutputStream;
import java.io.IOException;

public class OutputStream {

	public static void main(String[] args) {
		FileOutputStream fos = null;
		try {
			// 创建输出流对象（(FileOutputStream)）
			fos = new FileOutputStream("e:/t01/hello.txt",true);
			// 写入文本文件（write()）
			String str = "好好学习，天天向上";
			fos.write(str.getBytes(), 0, str.getBytes().length);
		} catch (FileNotFoundException e) {
			// TODO Auto-generated catch block
			e.printStackTrace();
		} catch (IOException e) {
			// TODO Auto-generated catch block
			e.printStackTrace();
		}finally{
			try {
				// 关闭流
				fos.close();
			} catch (IOException e) {
				// TODO Auto-generated catch block
				e.printStackTrace();
			}
		}
	}
}
